package com.example.demo.controller;

import com.example.demo.entity.maintenance;
import com.example.demo.service.MaintenanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("main")
@CrossOrigin//允许跨域
@Api(tags= "维修相关操作类",value = "维修相关操作类")
public class Maintenance {
    @Resource
    MaintenanceService MaintenanceService;

    @PostMapping("/insert")
    @ApiOperation(value = "插入故障维修表",notes = "rkey为自增id，不用输入，wticketkey自动生成，插入成功返回wticketkey，一条故障只对应一条维修，重复fkey返回‘故障已维修’，插入失败返回‘维修单插入失败’")
    public String insert(@RequestBody maintenance maintenance)
    {return MaintenanceService.insert(maintenance);}

    @PostMapping("/query")
    @ApiOperation(value = "查询故障维修表",notes = "返回所有维修管理信息")
    public List query(){return MaintenanceService.query();}
}
